import { S } from '../../s';
import { IPSAppCodeList } from '../../app/codelist/ipsapp-code-list';
import { IPSAppDEDataSet } from '../../app/dataentity/ipsapp-dedata-set';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSControlAction } from '../ipscontrol-action';
import { PSMDAjaxControlContainerImpl2 } from '../psmdajax-control-container-impl2';
import { IPSDEGrid } from './ipsdegrid';
import { IPSDEGridColumn } from './ipsdegrid-column';
import { IPSDEGridDataItem } from './ipsdegrid-data-item';
import { IPSDEGridEditItem } from './ipsdegrid-edit-item';
import { IPSDEGridEditItemUpdate } from './ipsdegrid-edit-item-update';
import { IPSDEGridEditItemVR } from './ipsdegrid-edit-item-vr';
import { IPSLayoutPanel } from '../panel/ipslayout-panel';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDEGridImpl
  extends PSMDAjaxControlContainerImpl2
  implements IPSDEGrid
{
  get aggMode(): 'NONE' | 'PAGE' | 'ALL' {
    return this.M.aggMode;
  }

  protected aggpsappdedataset: IPSAppDEDataSet;
  getAggPSAppDEDataSet(): IPSAppDEDataSet | null {
    if (this.aggpsappdedataset != null) return this.aggpsappdedataset;
    const value = this.M.getAggPSAppDEDataSet;
    if (value == null) {
      return;
    }
    this.aggpsappdedataset =
      this.getAggPSAppDataEntity().findPSAppDEDataSet(value);
    return this.aggpsappdedataset;
  }

  protected aggpsappdataentity: IPSAppDataEntity;
  getAggPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.aggpsappdataentity ||
      (this.aggpsappdataentity = this.fillObjectModel(
        S._f,
        this.M.getAggPSAppDataEntity,
        S._357,
      ) as IPSAppDataEntity)
    );
  }

  protected aggpslayoutpanel: IPSLayoutPanel;
  getAggPSLayoutPanel(): IPSLayoutPanel | null {
    return (
      this.aggpslayoutpanel ||
      (this.aggpslayoutpanel = this.fillObjectModel(
        S._255,
        this.M.getAggPSLayoutPanel,
        S._386,
      ) as IPSLayoutPanel)
    );
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get columnEnableFilter(): 0 | 1 | 2 {
    return this.M.columnEnableFilter;
  }

  get columnEnableLink(): 0 | 1 | 2 {
    return this.M.columnEnableLink;
  }

  protected createpscontrolaction: IPSControlAction;
  getCreatePSControlAction(): IPSControlAction | null {
    return (
      this.createpscontrolaction ||
      (this.createpscontrolaction = this.fillObjectModel(
        S._92,
        this.M.getCreatePSControlAction,
        S._340,
      ) as IPSControlAction)
    );
  }

  get emptyText(): string {
    return this.M.emptyText;
  }

  protected emptytextpslanguageres: IPSLanguageRes;
  getEmptyTextPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.emptytextpslanguageres ||
      (this.emptytextpslanguageres = this.fillObjectModel(
        S._276,
        this.M.getEmptyTextPSLanguageRes,
        S._2b4,
      ) as IPSLanguageRes)
    );
  }

  get frozenFirstColumn(): number {
    return this.M.frozenFirstColumn != null ? this.M.frozenFirstColumn : 0;
  }

  get frozenLastColumn(): number {
    return this.M.frozenLastColumn != null ? this.M.frozenLastColumn : 0;
  }

  protected getdraftfrompscontrolaction: IPSControlAction;
  getGetDraftFromPSControlAction(): IPSControlAction | null {
    return (
      this.getdraftfrompscontrolaction ||
      (this.getdraftfrompscontrolaction = this.fillObjectModel(
        S._92,
        this.M.getGetDraftFromPSControlAction,
        S._341,
      ) as IPSControlAction)
    );
  }

  protected getdraftpscontrolaction: IPSControlAction;
  getGetDraftPSControlAction(): IPSControlAction | null {
    return (
      this.getdraftpscontrolaction ||
      (this.getdraftpscontrolaction = this.fillObjectModel(
        S._92,
        this.M.getGetDraftPSControlAction,
        S._342,
      ) as IPSControlAction)
    );
  }

  protected getpscontrolaction: IPSControlAction;
  getGetPSControlAction(): IPSControlAction | null {
    return (
      this.getpscontrolaction ||
      (this.getpscontrolaction = this.fillObjectModel(
        S._92,
        this.M.getGetPSControlAction,
        S._343,
      ) as IPSControlAction)
    );
  }

  get gridStyle():
    | 'TREEGRID'
    | 'GROUPGRID'
    | 'LIST'
    | 'LIST_SORT'
    | 'USER'
    | 'USER2' {
    return this.M.gridStyle;
  }

  get groupMode(): 'NONE' | 'AUTO' | 'CODELIST' {
    return this.M.groupMode;
  }

  protected grouppsappdefield: IPSAppDEField;
  getGroupPSAppDEField(): IPSAppDEField | null {
    return (
      this.grouppsappdefield ||
      (this.grouppsappdefield = this.fillObjectModel(
        S._1,
        this.M.getGroupPSAppDEField,
        S._34c,
      ) as IPSAppDEField)
    );
  }

  protected grouppscodelist: IPSAppCodeList;
  getGroupPSCodeList(): IPSAppCodeList | null {
    return (
      this.grouppscodelist ||
      (this.grouppscodelist = this.fillObjectModel(
        S._8,
        this.M.getGroupPSCodeList,
        S._34d,
      ) as IPSAppCodeList)
    );
  }

  get minorSortDir(): 'ASC' | 'DESC' {
    return this.M.minorSortDir;
  }

  protected minorsortpsappdefield: IPSAppDEField;
  getMinorSortPSAppDEField(): IPSAppDEField | null {
    return (
      this.minorsortpsappdefield ||
      (this.minorsortpsappdefield = this.fillObjectModel(
        S._1,
        this.M.getMinorSortPSAppDEField,
        S._2b9,
      ) as IPSAppDEField)
    );
  }

  protected ordervaluepsappdefield: IPSAppDEField;
  getOrderValuePSAppDEField(): IPSAppDEField | null {
    return (
      this.ordervaluepsappdefield ||
      (this.ordervaluepsappdefield = this.fillObjectModel(
        S._1,
        this.M.getOrderValuePSAppDEField,
        S._354,
      ) as IPSAppDEField)
    );
  }

  protected psdegridcolumns: IPSDEGridColumn[];
  getPSDEGridColumns(): IPSDEGridColumn[] | null {
    return (
      this.psdegridcolumns ||
      (this.psdegridcolumns = this.fillChildListModel(
        this.M.getPSDEGridColumns,
        S._c6,
      ) as IPSDEGridColumn[])
    );
  }

  findPSDEGridColumn(objKey: any): IPSDEGridColumn | null {
    return this.getPSModel5(
      S._c6,
      this.getPSDEGridColumns(),
      objKey,
    ) as IPSDEGridColumn;
  }

  protected psdegriddataitems: IPSDEGridDataItem[];
  getPSDEGridDataItems(): IPSDEGridDataItem[] | null {
    return (
      this.psdegriddataitems ||
      (this.psdegriddataitems = this.fillChildListModel(
        this.M.getPSDEGridDataItems,
        S._28f,
      ) as IPSDEGridDataItem[])
    );
  }

  findPSDEGridDataItem(objKey: any): IPSDEGridDataItem | null {
    return this.getPSModel5(
      S._28f,
      this.getPSDEGridDataItems(),
      objKey,
    ) as IPSDEGridDataItem;
  }

  protected psdegridedititemupdates: IPSDEGridEditItemUpdate[];
  getPSDEGridEditItemUpdates(): IPSDEGridEditItemUpdate[] | null {
    return (
      this.psdegridedititemupdates ||
      (this.psdegridedititemupdates = this.fillChildListModel(
        this.M.getPSDEGridEditItemUpdates,
        S._c7,
      ) as IPSDEGridEditItemUpdate[])
    );
  }

  findPSDEGridEditItemUpdate(objKey: any): IPSDEGridEditItemUpdate | null {
    return this.getPSModel5(
      S._c7,
      this.getPSDEGridEditItemUpdates(),
      objKey,
    ) as IPSDEGridEditItemUpdate;
  }

  protected psdegridedititemvrs: IPSDEGridEditItemVR[];
  getPSDEGridEditItemVRs(): IPSDEGridEditItemVR[] | null {
    return (
      this.psdegridedititemvrs ||
      (this.psdegridedititemvrs = this.fillChildListModel(
        this.M.getPSDEGridEditItemVRs,
        S._c8,
      ) as IPSDEGridEditItemVR[])
    );
  }

  findPSDEGridEditItemVR(objKey: any): IPSDEGridEditItemVR | null {
    return this.getPSModel5(
      S._c8,
      this.getPSDEGridEditItemVRs(),
      objKey,
    ) as IPSDEGridEditItemVR;
  }

  protected psdegridedititems: IPSDEGridEditItem[];
  getPSDEGridEditItems(): IPSDEGridEditItem[] | null {
    return (
      this.psdegridedititems ||
      (this.psdegridedititems = this.fillChildListModel(
        this.M.getPSDEGridEditItems,
        S._c4,
      ) as IPSDEGridEditItem[])
    );
  }

  findPSDEGridEditItem(objKey: any): IPSDEGridEditItem | null {
    return this.getPSModel5(
      S._c4,
      this.getPSDEGridEditItems(),
      objKey,
    ) as IPSDEGridEditItem;
  }

  get pagingSize(): number {
    return this.M.pagingSize;
  }

  protected removepscontrolaction: IPSControlAction;
  getRemovePSControlAction(): IPSControlAction | null {
    return (
      this.removepscontrolaction ||
      (this.removepscontrolaction = this.fillObjectModel(
        S._92,
        this.M.getRemovePSControlAction,
        S._345,
      ) as IPSControlAction)
    );
  }

  get sortMode(): 'REMOTE' | 'LOCAL' {
    return this.M.sortMode;
  }

  protected updatepscontrolaction: IPSControlAction;
  getUpdatePSControlAction(): IPSControlAction | null {
    return (
      this.updatepscontrolaction ||
      (this.updatepscontrolaction = this.fillObjectModel(
        S._92,
        this.M.getUpdatePSControlAction,
        S._346,
      ) as IPSControlAction)
    );
  }

  hasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  get enableColFilter(): boolean {
    return this.M.enableColFilter;
  }

  get enableCustomized(): boolean {
    return this.M.enableCustomized;
  }

  get enableGroup(): boolean {
    return this.M.enableGroup;
  }

  get enablePagingBar(): boolean {
    return this.M.enablePagingBar;
  }

  get enableRowEdit(): boolean {
    return this.M.enableRowEdit;
  }

  get enableRowEditOrder(): boolean {
    return this.M.enableRowEditOrder;
  }

  get enableRowNew(): boolean {
    return this.M.enableRowNew;
  }

  get forceFit(): boolean {
    return this.M.forceFit;
  }

  get hideHeader(): boolean {
    return this.M.hideHeader;
  }

  get noSort(): boolean {
    return this.M.noSort;
  }

  get singleSelect(): boolean {
    return this.M.singleSelect;
  }
  get cls(): string {
    return 'PSDEGridImpl';
  }
  instanceof(cls: string): boolean {
    if (
      cls == S._217 ||
      cls == S._214 ||
      cls == S._1f ||
      cls == S._24a ||
      cls == S._244 ||
      cls == S._245 ||
      cls == S._246 ||
      cls == S._24d
    )
      return true;
    return super.instanceof(cls);
  }
}
